$(document).ready(function(){
    $('#find-cat').click(function(e){
        e.preventDefault();
        var is_hidden = $('#cat-form').is(":visible");
        if(is_hidden){
            $('#find-cat').prop('title',"Click to show");
            $('#cat-form').fadeOut("slow");
            $('#cats').fadeOut("slow");
        }else{
            $('#find-cat').prop('title',"Click to hide");
            $('#cat-form').fadeIn("slow");
            $('#cats').fadeIn("slow");
        }
    });
    $('#likes').click(function(){
        var catid;
        catid = $(this).attr("data-catid");
        $.get('/rango/like_category/', {category_id: catid}, function(data){
           $('#like_count').html(data);
           $('#likes').hide();
       });
    });
    $('#suggestion').keyup(function(){
        var query;
        query = $(this).val();
        $.get('/rango/suggest_category/', {suggestion: query}, function(data){
            $('#cats').html(data);
        });
    });
});
